/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.marco_paoletti;
import java.sql.*;

/**
 *
 * @author cloud
 */
public class DbManager {
    public void accessDb() {
        String url = "jdbc:derby://localhost:1527/sample";
        String user = "app";
        String pwd= "app";
        try {
           DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
           Connection c = DriverManager.getConnection(url,user,pwd);
           Statement st = c.createStatement();
           ResultSet rs = st.executeQuery("SELECT * FROM CUSTOMER");
           
           while ( rs.next() ) {
               System.out.println("NAME = "+rs.getString("NAME")+" ,CITY= "+ rs.getString("CITY"));  
           }
           //importante
            rs.close();
            st.close();
            c.close();
        }
        catch(SQLException e) {
            System.out.println(e.getMessage());
        }
    }
    
}
